using System.Linq;
using CthulhuDomain.GameEntities;
using Microsoft.Xna.Framework.Input;

namespace CthulhuDomain.Strategies
{
  public class UserMovement : MovementStrategy
  {
    public UserMovement(DomainEntity subject) : base(subject) { }

    public override void Move(IRectangle context, Keys[] keys)
    {
      if (keys.Contains(Keys.Right) && Subject.Position.X + Subject.Width <= context.Width)
        Subject.Position.X += Subject.Speed;

      if (keys.Contains(Keys.Left) && Subject.Position.X > 0)
        Subject.Position.X -= Subject.Speed;

      if (keys.Contains(Keys.Space) && Subject.Shoots.All(x => x == null)) Subject.AddShoot();
    }
  }
}